import React from 'react'
import { Menu, message } from 'antd';
import HTTP from '../../services/api';
import signApi from '../../api/sign.api';
import { history } from 'umi';
const { SubMenu } = Menu
export default class Tools extends React.Component {
    constructor() {
        super()
    }
    sign = async type => {
        let result = await HTTP({ method: 'post' }, signApi.WorkerSign, { type })
        try {
            if (result.status) {
                message.success(result.msg)
            } else {
                message.error(result.msg)
            }
        } catch (error) {
            message.error(result.msg)
        }
    }
    render() {
        return (
            <>
                <Menu>
                    <SubMenu key="sub1" title="用户中心">
                        <SubMenu key="456" title="签到">
                            <Menu.Item onClick={() => { this.sign(1) }} key="50">上班签到</Menu.Item>
                            <Menu.Item onClick={() => { this.sign(0) }} key="60">下班签到</Menu.Item>
                        </SubMenu>
                        <Menu.Item key="6">查看个人信息</Menu.Item>
                        <Menu.Item onClick={()=>{history.push('/message/show')}} key="7">查看消息</Menu.Item>
                        <Menu.Item onClick={()=>{history.push('/message')}} key="8">发布消息</Menu.Item>
                    </SubMenu>
                </Menu>
            </>
        )
    }
}